﻿<%@ WebHandler Language="C#" Class="upload" %>

using System;
using System.Web;
using System.IO;

public class upload : IHttpHandler {
    
    public void ProcessRequest (HttpContext context) {
        HttpPostedFile file = context.Request.Files["Filedata"];

        string targetDirectory = Path.Combine(context.Request.PhysicalApplicationPath, context.Request["folder"].Replace("/",""));
        string targetFilePath = Path.Combine(targetDirectory, file.FileName);

        // Uncomment the following line if you want to make the directory if it doesn't exist
        //if (!Directory.Exists(targetDirectory)) Directory.CreateDirectory(targetDirectory);

        file.SaveAs(targetFilePath);

        context.Response.Write("1");
        
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }

}